<template>
	<view class="container">
		<!-- 商品图片 -->
		<view class="product-image" :style="{'background-image': 'url('+product.image+')'}">
			<view class="product-image-box">
				<image class="product-image-box-img" :src="product.image" mode="aspectFill"></image>
				<view class="product-image-r">
					<view class="product-image-r-title">
						{{ product.title }}
					</view>
					<view class="product-image-r-time">
						{{ product.time }}
					</view>
					<view class="product-image-r-info">
						以现场为准
					</view>
				</view>
			</view>
		</view>
		<view class="container-box">
			<view style="padding-top: 10px;"></view>
			<!-- 商品标题和价格 -->
			<view class="product-info">
				<view class="product-info-l">
					<view class="product-price">￥<text class="plan-price-text">{{ product.price }}</text></view>
					<text class="product-title">济南市-山东省会大剧院歌剧厅</text>
				</view>
				<view class="product-info-r">
					<image class="product-info-r-img" src="@/static/img/share.png" mode="aspectFill"></image>
				</view>
			</view>
			<!-- 参数选择 -->
			<view class="menu-list">
				<view v-for="(item, index) in menuItems" :key="index" class="menu-item"
					@click="onMenuItemClick(item,index)">

					<!-- 菜单文字 -->
					<view class="menu-text"><i :class="['iconfont',item.icon] " /> <text>{{ item.name }}</text></view>
					<!-- 右箭头图标 -->
					<image src="@/static/img/godtail.png" mode="widthFix" class="arrow-icon"></image>
				</view>
			</view>
			<!-- 关注-想看 -->
			<view class="collect">
				<!-- <view class="collect-top">
					<i>关注</i>
				</view> -->
				<view class="collect-center">
					<view class="collect-center-num">100<text class="collect-center-num-text">人关注</text></view>
					<view class="collect-center-btn">
						<text :class="['iconfont', isFavorite ? 'icon-shoucang1' : 'icon-shoucang']"></text> 关注
					</view>
				</view>
				<swiper class="swiper1" :indicator-dots="indicatorDots1" :circular="circular1" :vertical="vertical1"
					:autoplay="autoplay1" indicator-active-color="#ffffff" indicator-color='rgba(238,238,238,1)'
					:interval="interval1" :duration="duration1">
					<swiper-item v-for="(item,index) in NewsList" :key="index">
						<view class="swiper1View">
							{{item.title}}
						</view>
					</swiper-item>
				</swiper>
			</view>
			
			<view class="detail">
				<view class="detail-title">
					演出介绍
				</view>
				<image class="detail-img" src="@/static/img/d1.jpg" mode="aspectFill"></image>
				<image class="detail-img" src="@/static/img/d2.jpg" mode="aspectFill"></image>
				<image class="detail-img" src="@/static/img/d3.jpg" mode="aspectFill"></image>
			</view>
			<view style="display: none;">
				<!-- 商品规格选择 -->
				<view class="product-specs">
					<text class="specs-title">选择规格</text>
					<view class="specs-list">
						<text v-for="(spec, index) in product.specs" :key="index"
							:class="['spec-item', { active: selectedSpec === spec }]" @click="selectSpec(spec)">
							{{ spec }}
						</text>
					</view>
				</view>

				<!-- 购买数量 -->
				<view class="product-quantity">
					<text class="quantity-title">购买数量</text>
					<view class="quantity-control">
						<text class="quantity-btn" @click="decreaseQuantity">-</text>
						<text class="quantity-value">{{ quantity }}</text>
						<text class="quantity-btn" @click="increaseQuantity">+</text>
					</view>
				</view>

				<!-- 运费信息 -->
				<view class="shipping-info">
					<text class="shipping-title">运费</text>
					<text class="shipping-value">¥{{ product.shipping }}</text>
				</view>
			</view>

			<!-- 购买按钮 -->
			<view class="bottom-menu">
				<view class="" style="flex: 1;display: flex;">
					<view class="menu-item" @click="goHome">
						<text class="iconfont icon-home"></text>
						<text class="menu-text">首页</text>
					</view>
					<view class="menu-item" @click="toggleFavorite">
						<text :class="['iconfont', isFavorite ? 'icon-shoucang1' : 'icon-shoucang']"></text>
						<text class="menu-text">收藏</text>
					</view>
					<view class="menu-item" @click="goCart">
						<text class="iconfont icon-gouwuchekong"></text>
						<text class="menu-text">购物车</text>
					</view>
				</view>
				<view class="menu-action">
					<button class="add-cart-btn" @click="handleAddToCart">加入购物车</button>
					<button class="buy-btn" @click="handleBuy">立即购买</button>
				</view>
			</view>
		</view>

		<!-- 个人喜好弹窗  -->
		<likeModel ref="likeModel" />
		<info ref="info" />
		<spec ref="spec" />
	</view>
</template>

<script>
	import likeModel from './component/lickModel/likeModel.vue'
	import info from './component/lickModel/info.vue'
	import spec from './component/lickModel/spec.vue'
	export default {
		components: {
			likeModel,
			info,
			spec,
		},
		data() {
			return {
				NewsList:[{title:'人气飙升中'},{title:'标记收藏让我更懂你'}],
				// 多少人想看的 轮播
				indicatorDots1: false,
				autoplay1: true,
				vertical1: true,
				interval1: 5000,
				duration1: 1000,
				circular1: true,
				product: {
					image: 'https://qcloud.dpfile.com/pc/_22NoSoft3aE6EJvPPVKZl7azJnSbjQvlobQc1TprekID0bsu-SAtCe9N8iBmkY3.jpg', // 商品图片
					title: '[南宁][送机酒保障/酒店权益][强实名/有条件退款]周杰伦2025“嘉年华”世界巡回演唱会', // 商品标题
					price: 99.9, // 商品价格
					specs: ['黑色', '白色', '灰色', '蓝色'], // 商品规格
					shipping: 10, // 运费
					time: '2025.04.12'
				},
				isFavorite: false,
				// 菜单项数据
				menuItems: [{
						id: 0,
						name: '参数:商品条码 净含量..',
						path: '/page_wallet/qualificationInfo',
						icon: 'icon-suo',
					},
					{
						id: 1,
						name: '保障:7天无理由退货·品质保障·特色服务体险',
						icon: 'icon-iconmanzutiaojian',
					},
					{
						id: 2,
						name: '规格·参数·类型',
						icon: 'icon-yaoqing',
					},
				],
				selectedSpec: '', // 选中的规格
				quantity: 1, // 购买数量
			};
		},
		methods: {
			// 选择规格
			selectSpec(spec) {
				this.selectedSpec = spec;
			},
			// 减少数量
			decreaseQuantity() {
				if (this.quantity > 1) {
					this.quantity--;
				}
			},
			// 增加数量
			increaseQuantity() {
				this.quantity++;
			},
			// 规则弹窗
			onMenuItemClick(item, index) {
				if (index == 0) {
					this.$nextTick(() => {
						this.$refs['likeModel'].open()
					})
				} else if (index == 1) {
					this.$nextTick(() => {
						this.$refs['info'].open()
					})
				} else if (index == 2) {
					this.$nextTick(() => {
						this.$refs['spec'].open()
					})
				}

			},
			// 立即购买
			handleBuy() {
				uni.showToast({
					title: '立即购买',
					icon: 'none',
				});
			},
			// 加入购物车
			handleAddToCart() {
				uni.showToast({
					title: '已加入购物车',
					icon: 'success',
				});
			},
		},
	};
</script>

<style lang="less" scoped>
	page {
		width: 100%;
		height: 100%;
		background: #f2f2fa;
	}

	.container-box {
		padding: 0 20rpx;
		background: #f2f2fa;
		box-sizing: border-box;
		border-radius: 60rpx 60rpx 0 0;
		margin-top: -90rpx;
		position: relative;
	}

	.product-image {
		width: 100%;
		height: 360rpx;
		overflow: hidden;
		background-position: center center;
		background-size: cover;
		position: relative;
		z-index: 0;

		.product-image-box {
			position: absolute;
			top: 0;
			right: 0;
			bottom: 0;
			left: 0;
			background-color: rgba(0, 0, 0, 0.6);
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			padding: 30rpx 25rpx;
			box-sizing: border-box;

			.product-image-box-img {
				width: 170rpx;
				height: 220rpx;
				border-radius: 6rpx;
			}

			.product-image-r {
				flex: 1;
				margin-left: 30rpx;
				color: white;

				.product-image-r-title {
					font-size: 30rpx;
					font-weight: bold;
					height: 150rpx;
				}

				.product-image-r-time {
					font-size: 28rpx;
				}

				.product-image-r-info {
					font-size: 28rpx;
					opacity: .7;
					margin-top: 5rpx;
				}
			}
		}
	}

	.image {
		width: 100%;
		height: 100%;
	}

	.product-info {
		box-sizing: border-box;
		padding: 10rpx 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		border-radius: 6rpx;

		.product-info-l {
			font-size: 28rpx;
		}

		.product-info-r {
			margin-top: 10rpx;

			.product-info-r-img {
				width: 30rpx;
				height: 30rpx;
			}
		}
	}

	.product-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}

	.product-price {
		display: block;
		font-size: 20rpx;
		color: #e64340;
		font-weight: bold;

		.plan-price-text {
			font-size: 40rpx;
			margin-left: 5rpx;

		}
	}

	.product-specs {
		margin-top: 30rpx;
	}

	.specs-title {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}

	.specs-list {
		margin-top: 20rpx;
		display: flex;
		flex-wrap: wrap;
	}

	.spec-item {
		padding: 15rpx 30rpx;
		margin-right: 20rpx;
		margin-bottom: 20rpx;
		border: 1rpx solid #ccc;
		border-radius: 10rpx;
		font-size: 28rpx;
		color: #666;
	}

	.spec-item.active {
		border-color: #e64340;
		color: #e64340;
		background-color: #ffe6e6;
	}

	.product-quantity {
		margin-top: 30rpx;
	}

	.quantity-title {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}

	.quantity-control {
		margin-top: 20rpx;
		display: flex;
		align-items: center;
	}

	.quantity-btn {
		width: 60rpx;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		border: 1rpx solid #ccc;
		border-radius: 10rpx;
		font-size: 32rpx;
		color: #666;
	}

	.quantity-value {
		margin: 0 30rpx;
		font-size: 32rpx;
		color: #333;
	}

	.shipping-info {
		margin-top: 30rpx;
	}

	.shipping-title {
		font-size: 32rpx;
		color: #333;
		font-weight: bold;
	}

	.shipping-value {
		display: block;
		margin-top: 10rpx;
		font-size: 28rpx;
		color: #666;
	}

	.action-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-between;
		padding: 20rpx;
		background-color: #fff;
		border-top: 1rpx solid #eee;
	}

	/* 底部菜单栏 */
	.bottom-menu {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		align-items: center;
		background-color: #fff;
		border-top: 1rpx solid #eee;
		padding-right: 10rpx;
		height: 120rpx;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1);

		.menu-item {
			width: 100rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			font-size: 24rpx;
			color: #666;
		}

		.menu-item .iconfont {
			font-size: 40rpx;
		}

		.menu-action {
			display: flex;
			justify-content: space-between;
		}

		.add-cart-btn,
		.buy-btn {
			height: 80rpx;
			line-height: 80rpx;
			text-align: center;
			font-size: 32rpx;
			color: #fff;
		}

		.add-cart-btn {
			border-radius: 40rpx 0 0 40rpx;
			background-image: linear-gradient(to right, #ff7e5f, #feb47b)
		}

		.buy-btn {
			border-radius: 0 40rpx 40rpx 0;
			background-image: linear-gradient(to right, #ff7e5f, #e64340)
		}

	}

	.menu-list {
		box-sizing: border-box;
		padding: 20rpx 30rpx;
		background-color: #fff;
		margin-top: 20rpx;
		border-radius: 10rpx;

		.menu-item {
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			border-bottom: 1px solid #f5f5f5;
		}

		.menu-text {
			font-size: 28rpx;
			color: #333;
			display: flex;
			align-items: center;

			.iconfont {
				color: #333;
			}
		}

		.arrow-icon {
			width: 15rpx;
			height: 15rpx;
		}
	}

	.collect {
		// height: 125rpx;
		width: 100%;
		margin-top: 20rpx;
		border-radius: 10rpx;
		padding: 20rpx 30rpx;
		box-sizing: border-box;
		background: linear-gradient(to right top, #ffffff, #f8f2e7);
		position: relative;

		.collect-top {
			border-radius: 0 0 70rpx 0;
			background: linear-gradient(to right top, #fff9ef, #ffeee4);
			position: absolute;
			left: 0;
			top: 0;
			width: 270rpx;
			height: 70rpx;
			display: flex;
			align-items: center;
			justify-content: center;

		}

		.collect-center {
			width: 100%;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.collect-center-num {
				flex: 1;
				color: #fc9425;
				font-size: 55rpx;

				.collect-center-num-text {
					font-size: 20rpx;
					color: #333333;
					margin-left: 5rpx;
				}
			}

			.collect-center-btn {
				width: 135rpx;
				height: 50rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				background: linear-gradient(to right top, #fcbe51, #fea338);
				border-radius: 50rpx;
				font-size: 20rpx;
				color: white;

				.iconfont {
					margin-right: 5rpx;
				}
			}
			
		}
		.swiper1 {
			height: 60rpx;
			box-sizing: border-box;
			font-size: 24rpx;
			color: #a6a4a5;
			line-height: 60rpx;
			overflow: hidden;
		
			.swiper1View {
				white-space: nowrap;
			}
		}
	}

	.detail {
		border-radius: 10rpx;
		box-sizing: border-box;
		padding:0 30rpx 20rpx 30rpx;
		background-color: #ffffff;
		margin-top: 20rpx;
		.detail-title{
			height: 90rpx;
			font-size: 26rpx;
			box-sizing: border-box;
			line-height: 90rpx;
		}
		.detail-img {
			width: 100%;
		}

	}

	.popup-content {
		width: calc(100vw - 132px);
		padding: 20px;
		background-color: #1b1b1b;
		border-radius: 10px;

		.title {
			display: flex;
			align-items: center;
			margin-bottom: 10px;
			justify-content: center;

			img {
				width: 20px;
				height: 20px;
				margin-right: 6px;
			}

			span {
				font-size: 16px;
				color: white;
			}
		}

		.content {
			font-size: 14px;
			color: white;
			text-align: center;
		}

		.btn {
			background: #f5cd47;
			border-radius: 6px;
			border: 1px solid rgba(255, 255, 255, 0.14);
			height: 44px;
			text-align: center;
			line-height: 44px;
			margin-top: 20px;
		}
	}
</style>